|
|
|
|
|
|
|
the object's type library. Using a type library is an obvious approachit allows you to use the Enum list as a data type, making it easy for people using the object to select values for parameters. The Enum list will appear in the object browser and screen tips while you are coding. The constant approach is reasonable for classes that are designed to be incorporated directly into applications instead of deployed as components. |
|
|
|
|
|
|
|
|
You might think that Enums have such an overwhelming advantage that you should always use them as constants. In theory, this is true, but I've found that public Enums tend to destabilize components in ways that are not particularly reproducible. Every time I've run into a program that spontaneously crashes even with correct code, or for which I cannot maintain binary compatibility, it's always turned out that the way to solve the problem involved eliminating the public Enumsor at least not use them as parameters or return values for methods or properties. |
|
|
|
|
|
|
|
|
For that reason, I tend to avoid using them as data types, but in this particular sample program the classes are intended to be incorporated directly into applications, so I took the preferred approach in the hope that VB6 is more stable in the way it handles these data types. The ServiceControlRights Enum shown here specifies the type of rights that are requested for use with the Service Control Manager. The ServiceAccessRights Enum specifies the types of rights that are requested for the service object itself. The ServiceControlConstants Enum specifies the operations that are available when using the ServiceControl API function. The ServiceStateConstants Enum contains constants describing the running state of a service. |
|
|
|
|
|
|
|
|
' Service Control Manager Class
' Copyright © 1998 by Desaware Inc. All Rights Reserved
Option Explicit
' Service constants exposed via typelib
Public Enum ServiceControlRights
SC_MANAGER_CONNECT = 1
SC_MANAGER_CREATE_SERVICE = 2
SC_MANAGER_ENUMERATE_SERVICE = 4
SC_MANAGER LOCK = 8
SC_MANAGER OUERY_LOCK_STATUS = &H10
SC_MANAGER MODIFY BOOT CONFIG = &H20
SC_MANAGER_ALL_ACCESS = &H3F Or STANDARD_RIGHTS_REOUIRED
End Enum |
|
|
|
|
|